package cn.fx.framework.cons;

/**
 * ErrorCodeMessage枚举类，定义项目开发中经常使用的错误代码与信息
 * @author fxcn
 * @date 2024-9-29
 */
public enum ErrorCodeMessage {
    BAD_REQUEST_EXCEPTION_MSG (400, "错误的请求"),
    INVOKE_TIMEOUT_EXCEPTION_MSG(408, "调用超时"),
    REMOTE_INVOKE_EXCEPTION_MSG(499, "接口调用失败"),
    METHOD_INVOKE_EXCEPTION_MSG(498, "方法调用失败"),
    REPEAT_REQUEST_MSG(497, "重复请求"),
    REQUEST_SIGN_ERROR_MSG(496, "签名错误"),
    /**对应500异常码*/
    SERVER_ERROR_MSG(500, "服务器发生错误了"),
    INVALID_REQUEST_PARAMETER_EXCEPTION_MSG(469, "请求参数非法"),
    COLLECTION_NULL_OR_EMPTY_EXCEPTION_MSG(468, "集合NULL或为空"),
    SERVICE_EXCEPTION_MSG(444, "业务逻辑异常"),
    SERVICE_CHECK_EXCEPTION_MSG(408, "业务逻辑校验异常"),
    PERMISSION_EXCEPTION_MSG(489, "权限检验异常"),
    DATATYPE_CONVERT_EXCEPTION(487, "数据类型转换异常"),
    DATABASE_TABLE_UNIQUE_EXCEPTION(486, "违反数据库唯一键约束异常"),
    ENTITY_NOT_FOUND_EXCEPTION(485, "实体未查到"),
    AUTHORIZATION_EXCEPTION_MSG(401, "授权异常"),
    INVALID_ARGS_EXCEPTION(495, "无效的参数"),
    BASE_EXCEPTION_MSG(999, "自定义通用异常");

    private int code;

    private String message;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    private ErrorCodeMessage(int code, String message){
        this.code = code;
        this.message = message;
    }

    public String toString(){
        return "{\"ErrorCodeMessage\":{" +
                "\"code\":" + code +
                ", \"message\":\"" + message + "\"" +
                "}}";
    }
}
